<template>
  <div class="app-container">
    <div class="container">
      <div class="container-warp container-left" style="height: 275px;padding: 5px 10px 0;">
        <div class="table-title">材料性能</div>
        <el-row :gutter="20">
          <el-col :span="7">
            <div class="material-pic">
              <img src="@/assets/images/fkm.jpg">
            </div>
          </el-col>
          <el-col :span="10" class="material-form1">
            <el-form ref="mform" :model="form" label-width="80px" :inline="true" label-position="left" :rules="mrules">
              <el-form-item style="text-align:right">
                <template solt="label">
                  <div class="label-subscript">
                    <el-tooltip content="应力比为0.5，结构抵抗正应力致失效的疲劳强度范围ΔσC [MPa]" placement="top" effect="light">
                      <div>
                        ΔσC
                      </div>
                    </el-tooltip>
                  </div>
                </template>
              </el-form-item>
              <el-form-item prop="ddc">
                <el-input v-model="form.ddc" placeholder="" type="number"></el-input>
              </el-form-item>
              <el-form-item style="text-align:right">
                <template solt="label">
                  <div class="label-subscript">
                    <el-tooltip content="应力比为0.5，结构抗剪疲劳强度范围ΔτC [MPa]" placement="top" effect="light">
                      <div>
                        ΔτC
                      </div>
                    </el-tooltip>
                  </div>
                </template>
              </el-form-item>
              <el-form-item prop="dtc">
                <el-input v-model="form.dtc" placeholder="" type="number"></el-input>
              </el-form-item>

              <el-form-item style="text-align:right">
                <template solt="label">
                  <div class="label-subscript">
                    <el-tooltip content="S-N左侧边界" placement="top" effect="light">
                      <div>
                        N0
                      </div>
                    </el-tooltip>
                  </div>
                </template>
              </el-form-item>
              <el-form-item prop="snleft">
                <el-input v-model="form.snleft" placeholder="" type="number"></el-input>
              </el-form-item>
              <el-form-item style="text-align:right">
                <template solt="label">
                  <div class="label-subscript">
                    <el-tooltip content="τ-N左侧边界" placement="top" effect="light">
                      <div>
                        N0
                      </div>
                    </el-tooltip>
                  </div>
                </template>
              </el-form-item>
              <el-form-item prop="tnleft">
                <el-input v-model="form.tnleft" placeholder="" type="number"></el-input>
              </el-form-item>

              <el-form-item style="text-align:right">
                <template solt="label">
                  <div class="label-subscript">
                    <el-tooltip content="S-N第一个转折点循环数" placement="top" effect="light">
                      <div>
                        ND
                      </div>
                    </el-tooltip>
                  </div>
                </template>
              </el-form-item>
              <el-form-item prop="sn1for">
                <el-input v-model="form.sn1for" placeholder="" type="number"></el-input>
              </el-form-item>
              <el-form-item style="text-align:right">
                <template solt="label">
                  <div class="label-subscript">
                    <el-tooltip content="τ-N第一个转折点循环数" placement="top" effect="light">
                      <div>
                        ND
                      </div>
                    </el-tooltip>
                  </div>
                </template>
              </el-form-item>
              <el-form-item prop="tn1for">
                <el-input v-model="form.tn1for" placeholder="" type="number"></el-input>
              </el-form-item>

              <el-form-item style="text-align:right">
                <template solt="label">
                  <div class="label-subscript">
                    <el-tooltip content="S-N第二个转折点循环数" placement="top" effect="light">
                      <div>
                        NL
                      </div>
                    </el-tooltip>
                  </div>
                </template>
              </el-form-item>
              <el-form-item prop="sn2for">
                <el-input v-model="form.sn2for" placeholder="" type="number"></el-input>
              </el-form-item>
              <el-form-item style="text-align:right">
                <template solt="label">
                  <div class="label-subscript">
                    <el-tooltip content="τ-N第二个转折点循环数" placement="top" effect="light">
                      <div>
                        NL
                      </div>
                    </el-tooltip>
                  </div>
                </template>
              </el-form-item>
              <el-form-item prop="tn2for">
                <el-input v-model="form.tn2for" placeholder="" type="number"></el-input>
              </el-form-item>

              <el-form-item style="text-align:right">
                <template solt="label">
                  <div class="label-subscript">
                    <el-tooltip content="ΔσC [MPa]对应循环数" placement="top" effect="light">
                      <div>
                        NC
                      </div>
                    </el-tooltip>
                  </div>
                </template>
              </el-form-item>
              <el-form-item prop="ddcfor">
                <el-input v-model="form.ddcfor" placeholder="" type="number"></el-input>
              </el-form-item>
              <el-form-item style="text-align:right">
                <template solt="label">
                  <div class="label-subscript">
                    <el-tooltip content="ΔτC [MPa]对应循环数%" placement="top" effect="light">
                      <div>
                        NC
                      </div>
                    </el-tooltip>
                  </div>
                </template>
              </el-form-item>
              <el-form-item prop="dtcfor">
                <el-input v-model="form.dtcfor" placeholder="" type="number"></el-input>
              </el-form-item>

              <el-form-item style="text-align:right">
                <template solt="label">
                  <div class="label-subscript">
                    <el-tooltip content="S-N第一段斜率负倒数m1" placement="top" effect="light">
                      <div>
                        m1
                      </div>
                    </el-tooltip>
                  </div>
                </template>
              </el-form-item>
              <el-form-item prop="dm1">
                <el-input v-model="form.dm1" placeholder="" type="number"></el-input>
              </el-form-item>
              <el-form-item style="text-align:right">
                <template solt="label">
                  <div class="label-subscript">
                    <el-tooltip content="τ-N第一段斜率负倒数m1" placement="top" effect="light">
                      <div>
                        m1
                      </div>
                    </el-tooltip>
                  </div>
                </template>
              </el-form-item>
              <el-form-item prop="tm1">
                <el-input v-model="form.tm1" placeholder="" type="number"></el-input>
              </el-form-item>

              <el-form-item style="text-align:right">
                <template solt="label">
                  <div class="label-subscript">
                    <el-tooltip content="S-N第二段斜率负倒数m2" placement="top" effect="light">
                      <div>
                        m2
                      </div>
                    </el-tooltip>
                  </div>
                </template>
              </el-form-item>
              <el-form-item prop="dm2">
                <el-input v-model="form.dm2" placeholder="" type="number"></el-input>
              </el-form-item>
              <el-form-item style="text-align:right">
                <template solt="label">
                  <div class="label-subscript">
                    <el-tooltip content="τ-N第二段斜率负倒数m2" placement="top" effect="light">
                      <div>
                        m2
                      </div>
                    </el-tooltip>
                  </div>
                </template>
              </el-form-item>
              <el-form-item prop="tm2">
                <el-input v-model="form.tm2" placeholder="" type="number"></el-input>
              </el-form-item>
            </el-form>
          </el-col>
          <el-col :span="7">
            <div class="material-pic">
              <img src="@/assets/images/fkm.jpg">
            </div>
          </el-col>
        </el-row>
      </div>
      <div class="container-right">
        <div class="container-warp" style="height: 125px; padding: 5px 10px;">
          <div class="table-title">结构参数</div>
          <div class="structure-form">
            <el-form ref="jform" :model="form" label-width="60px" :inline="true" label-position="left"  :rules="jrules">
              <el-form-item label=""  prop="ft">
                <template solt="label">
                  <div class="label-subscript">
                    <el-tooltip content="尺寸修正系数f(t)" placement="top" effect="light">
                      <div>
                        f(t)
                      </div>
                    </el-tooltip>
                  </div>
                </template>
                <el-input v-model="form.ft" placeholder="" type="number">
                </el-input>
              </el-form-item>
              <el-form-item label=""  prop="wt">
                <template solt="label">
                  <div class="label-subscript">
                    <el-tooltip content="温度修正系数f(T)" placement="top" effect="light">
                      <div>
                        f(T)
                      </div>
                    </el-tooltip>
                  </div>
                </template>
                <el-input v-model="form.wt" placeholder="" type="number">
                  <el-button slot="append" @click="showWdModel2">
                    <svg-icon icon-class="calculator"/>
                  </el-button>
                </el-input>
              </el-form-item>
              <el-form-item label=""  prop="cv">
                <template solt="label">
                  <div class="label-subscript">
                    <el-tooltip content="损伤比较值CV" placement="top" effect="light">
                      <div>
                        CV
                      </div>
                    </el-tooltip>
                  </div>
                </template>
                <el-input v-model="form.cv" placeholder="" type="number">
                </el-input>
              </el-form-item>
              <el-form-item label=""  prop="ds">
                <template solt="label">
                  <div class="label-subscript">
                    <el-tooltip content="正应力谱下的临界损伤值DS" placement="top" effect="light">
                      <div>
                        DS
                      </div>
                    </el-tooltip>
                  </div>
                </template>
                <el-input v-model="form.ds" placeholder="" type="number">
                </el-input>
              </el-form-item>
              <el-form-item label=""  prop="dt">
                <template solt="label">
                  <div class="label-subscript">
                    <el-tooltip content="剪应力谱下的临界损伤值Dτ" placement="top" effect="light">
                      <div>
                        Dτ
                      </div>
                    </el-tooltip>
                  </div>
                </template>
                <el-input v-model="form.dt" placeholder="" type="number">
                </el-input>
              </el-form-item>
              <el-form-item label=""  prop="itr">
                <template solt="label">
                  <div class="label-subscript">
                    <el-tooltip content="材料类型" placement="top" effect="light">
                      <div>
                        Type<sub></sub>
                      </div>
                    </el-tooltip>
                  </div>
                </template>
                <el-select v-model="form.itr" placeholder="">
                    <el-option :label="item.label" :value="item.value" v-for="item in ITRSelectList"></el-option>
                </el-select>
              </el-form-item>
            </el-form>
          </div>
        </div>
        <div class="container-warp" style="height: 140px; padding: 5px 10px;">
          <div class="table-title">服役载荷</div>
          <div class="upload-file fyzh" style="margin-top: 10px;">
            <div>
              <!-- 文件列表 -->
              <transition-group class="upload-file-list el-upload-list el-upload-list--text" name="el-fade-in-linear" tag="ul">
                <li key="1123" class="el-upload-list__item ele-upload-list__item-content" style="border: none" v-for="(file, index) in fileList">
                  <span class="el-icon-document"> {{ file.name }} </span>
                </li>
              </transition-group>
            </div>
            <el-upload
              action="/"
              :before-upload="handleBeforeUpload"
              :file-list="fileList"
              :on-exceed="handleExceed"
              class="upload-file-uploader"
            >
                  <!-- :limit="limit" -->
              <!-- 上传按钮 -->
              <el-button size="mini" type="primary">选取正应力疲劳载荷谱文件</el-button>
              <!-- 上传提示 -->
              <div class="el-upload__tip" slot="tip" v-if="showTip">
                请上传
                <template v-if="fileSize"> 大小不超过 <b style="color: #f56c6c">{{ fileSize }}MB</b> </template>
                <template v-if="fileType"> 格式为 <b style="color: #f56c6c">{{ fileType.join("/") }}</b> </template>
                的文件
              </div>
            </el-upload>
          </div>
          <div class="upload-file fyzh">
            <div>
              <!-- 文件列表 -->
              <transition-group class="upload-file-list el-upload-list el-upload-list--text" name="el-fade-in-linear" tag="ul">
                <li key="1123" class="el-upload-list__item ele-upload-list__item-content" style="border: none" v-for="(file, index) in fileList2">
                  <span class="el-icon-document"> {{ file.name }} </span>
                </li>
              </transition-group>
            </div>
            <el-upload
              action="/"
              :before-upload="handleBeforeUpload2"
              :file-list="fileList2"
              :on-exceed="handleExceed"
              class="upload-file-uploader"
            >
                  <!-- :limit="limit" -->
              <!-- 上传按钮 -->
              <el-button size="mini" type="primary">选取切应力疲劳载荷谱文件</el-button>
              <!-- 上传提示 -->
              <div class="el-upload__tip" slot="tip" v-if="showTip">
                请上传
                <template v-if="fileSize"> 大小不超过 <b style="color: #f56c6c">{{ fileSize }}MB</b> </template>
                <template v-if="fileType"> 格式为 <b style="color: #f56c6c">{{ fileType.join("/") }}</b> </template>
                的文件
              </div>
            </el-upload>
  <!--            <el-button size="mini"  type="primary" class="detail-center-btn" @click="count(form)">
              <svg-icon icon-class="line-bar"/>
              计算
            </el-button> -->
          </div>
          <el-button type="primary" size="mini" style="float: right;" @click="count(form)"> <svg-icon icon-class="line-bar"/>计算</el-button>
        </div>
      </div>
    </div>
    <div class="line-warp"></div>
    <div class="container container-bottom">
      <div class="container-warp container-left" style="height: 100%;" >
        <div class="label-title">强度评价</div>
        <div class="label-log-form" v-if="showResult == true">
          <el-form ref="form" label-width="160px" :inline="true" label-position="left">
            <el-form-item label="" style="margin-right:20px">
              <template solt="label">
                <div class="label-subscript">
                  <el-tooltip content="损伤累积值" placement="top" effect="light">
                    <div>
                      损伤累积值
                    </div>
                  </el-tooltip>
                </div>
              </template>
              {{k0}}
            </el-form-item>
          </el-form>
        </div>
        <div  v-if="showResult == true" class="log-warp" :style="'height:'+logContentHeight+'px'">
          <div class="log-content divcontainer wrap-text" >
            <span class="badge" @click="showLogModel">
              <img src="@/assets/images/big_X.png" style="width: 30px;height: 30px;">
              </span>
            {{ logText }}
          </div>
        </div>
        <!-- <el-button type="primary" class="detail-center-btn" >
          <svg-icon icon-class="user-list"/>
          打开日志文件
        </el-button> -->
      </div>
      <div class="container-warp container-right">
        <div class="label-title" style="margin-bottom: 10px">结构S-N图</div>
        <el-carousel  v-if="showResult == true" arrow="always" class="chart-warp" :style="'height:'+(logContentHeight+50)+'px'">
          <el-carousel-item v-for="item in 2" :key="item">
            <sn-chart :chartData="getChartDataForItem(item)"  ref="snchart"/>
          </el-carousel-item>
        </el-carousel>
      </div>
    </div>
    <el-dialog
      width="80%"
      title="日志"
      :visible.sync="logModel"
      >
      <div class="wrap-text" :style="'height:'+ heightTestData +'px;overflow-y: auto;white-space:pre'">
        {{ logText }}
      </div>
    </el-dialog>
    <el-dialog
      width="40%"
      title="厚度-弯曲修正系数"
      :visible.sync="wdModel1"
      >
      <el-form ref="wform" class="dg-structure-form" :model="form" label-width="150px" :inline="true" label-position="left" :rules="wrules">
        <el-form-item  label=""  prop="materialtype">
          <template solt="label">
            <div class="dg-label-subscript">
              <el-tooltip content="材料类别" placement="top" effect="light">
                <div>
                  材料
                </div>
              </el-tooltip>
            </div>
          </template>
          <el-select v-model="form.materialtype" placeholder="">
            <el-option :label="item.label" :value="item.value" v-for="item in IMSelectList"></el-option>
          </el-select>
        </el-form-item>
        <el-form-item  label=""  prop="wd">
          <template solt="label">
            <div class="dg-label-subscript">
              <el-tooltip content="服役温度，℃" placement="top" effect="light">
                <div>
                  服役温度，℃
                </div>
              </el-tooltip>
            </div>
          </template>
          <el-input v-model="form.wd" placeholder="" type="number">
          </el-input>
        </el-form-item>
      </el-form>
      <el-button type="primary" class="detail-center-btn" @click="computeParamHD(form)">
        计算
      </el-button>
    </el-dialog>

    <el-dialog
      width="40%"
      title="温度修正系数"
      :visible.sync="wdModel2"
      >
      <el-form ref="wform" class="dg-structure-form" :model="form" label-width="150px" :inline="true" label-position="left" :rules="wrules">
        <el-form-item  label=""  prop="materialtype">
          <template solt="label">
            <div class="dg-label-subscript">
              <el-tooltip content="材料类别" placement="top" effect="light">
                <div>
                  材料
                </div>
              </el-tooltip>
            </div>
          </template>
          <el-select v-model="form.materialtype" placeholder="">
            <el-option :label="item.label" :value="item.value" v-for="item in IMSelectList"></el-option>
          </el-select>
        </el-form-item>
        <el-form-item  label=""  prop="wd">
          <template solt="label">
            <div class="dg-label-subscript">
              <el-tooltip content="服役温度，℃" placement="top" effect="light">
                <div>
                  服役温度，℃
                </div>
              </el-tooltip>
            </div>
          </template>
          <el-input v-model="form.wd" placeholder="" type="number">
          </el-input>
        </el-form-item>
      </el-form>
      <el-button type="primary" class="detail-center-btn" @click="computeParamWD(form)">
        计算
      </el-button>
    </el-dialog>
  </div>
</template>

<script>
  import service from "@/api/material";
  import SnChart from "./snChart";
  export default {
    name: "Iiw200829",
    components: {
      SnChart
    },
    props: {
      data: {
        type: Object
      },
      // 值
      value: [String, Object, Array],
      // 数量限制
      limit: {
        type: Number,
        default: 1,
      },
      // 大小限制(MB)
      fileSize: {
        type: Number,
        default: 5,
      },
      // 文件类型, 例如['png', 'jpg', 'jpeg']
      fileType: {
        type: Array,
        default: () => ["xlsx", "xls"],
      },
    },
    data() {
      return {
        showTip: false,
        mrules:{
          ddc: [{
            required: true,
            message: '应力比为0.5，结构抵抗正应力致失效的疲劳强度范围ΔσC [MPa]不能为空',
            trigger: 'blur'
          }],
          snleft: [{
            required: true,
            message: 'S-N左侧边界不能为空',
            trigger: 'blur'
          }],
          sn1for: [{
            required: true,
            message: 'S-N第一个转折点循环数不能为空',
            trigger: 'blur'
          }],
          sn2for: [{
            required: true,
            message: 'S-N第二个转折点循环数不能为空',
            trigger: 'blur'
          }],
          ddcfor: [{
            required: true,
            message: 'ΔσC [MPa]对应循环数不能为空',
            trigger: 'blur'
          }],
          dm1: [{
            required: true,
            message: 'S-N第一段斜率负倒数m1不能为空',
            trigger: 'blur'
          }],
          dm2: [{
            required: true,
            message: 'S-N第二段斜率负倒数m2不能为空',
            trigger: 'blur'
          }],
          dtc: [{
            required: true,
            message: '应力比为0.5，结构抗剪疲劳强度范围ΔτC [MPa]不能为空',
            trigger: 'blur'
          }],
          tnleft: [{
            required: true,
            message: 'τ-N左侧边界不能为空',
            trigger: 'blur'
          }],
          tn1for: [{
            required: true,
            message: 'τ-N第一个转折点循环数不能为空',
            trigger: 'blur'
          }],
          tn2for: [{
            required: true,
            message: 'τ-N第二个转折点循环数不能为空',
            trigger: 'blur'
          }],
          dtcfor: [{
            required: true,
            message: 'ΔτC [MPa]对应循环数%不能为空',
            trigger: 'blur'
          }],
          tm1: [{
            required: true,
            message: 'τ-N第一段斜率负倒数m1不能为空',
            trigger: 'blur'
          }],
          tm2: [{
            required: true,
            message: 'τ-N第二段斜率负倒数m2不能为空',
            trigger: 'blur'
          }],
        },
        jrules:{
          ft: [{
            required: true,
            message: '尺寸修正系数f(t)不能为空',
            trigger: 'blur'
          }],
          wt: [{
            required: true,
            message: '温度修正系数f(T)不能为空',
            trigger: 'blur'
          }],
          cv: [{
            required: true,
            message: '损伤比较值CV不能为空',
            trigger: 'blur'
          }],
          ds: [{
            required: true,
            message: '正应力谱下的临界损伤值DS不能为空',
            trigger: 'blur'
          }],
          dt: [{
            required: true,
            message: '剪应力谱下的临界损伤值Dτ不能为空',
            trigger: 'blur'
          }],
          itr: [{
            required: true,
            message: '残余应力类型不能为空',
            trigger: 'blur'
          }],
        },
        wrules:{
          materialtype: [{
            required: true,
            message: '材料类别不能为空',
            trigger: 'change'
          }],
          wd: [{
            required: true,
            message: '服役温度不能为空',
            trigger: 'blur'
          }]
        },
        form:{},
        item: [1],
        logText: '',
        control0: '',
        control1: '',
        control2: '',
        control3: '',
        control4: '',
        moduleClassSelectList: [
          {value: '1', label: '外推低周疲劳S-N形式',},
          {value: '2', label: '修正低周疲劳S-N形式',},
        ],
        JGSelectList: [
          {value: 0, label: '不修正',},
          {value: 1, label: '修正',},
        ],
        IMSelectList: [
          {value: 1, label: '钢铁',},
          {value: 2, label: '铝合金',},
        ],
        ITRSelectList: [
          {value: 1, label: '未焊基材',},
          {value: 2, label: '简单结构元件',},
          {value: 3, label: '复杂元件',},
        ],
        logModel: false,
        wdModel1: false,
        wdModel2: false,
        dllModel: false,
        heightTestData: '',
        logContentHeight: '',
        number: 0,
        uploadList: [],
        fileList: [],
        fileList2: [],
        dl: '',
        ts: '',
        abk: '',
        showResult: false,
        showSN: false,
        selectedLabel: "",
        loglineChartData1: {},
        loglineChartData2: {},
        loglineChartData3: {},
        loglineChartData4: {},
        selectedLabel1: "S-N曲线",
        selectedLabel2: "τ-N曲线",
        selectedLabel3: "BS7608改进性能后焊接接头疲劳寿命预测应力比R1<R≤R2时",
        selectedLabel4: "BS7608改进性能后焊接接头疲劳寿命预测应力比R≥R2时",
        k0: null,
      };
    },
    created() {
      this.logContentHeight = window.innerHeight - 500
    },
    watch: {
      value: {
        handler(val) {
          if (val) {
            let temp = 1;
            // 首先将值转为数组
            const list = Array.isArray(val) ? val : this.value.split(',');
            // 然后将数组转为对象数组
            this.fileList = list.map(item => {
              if (typeof item === "string") {
                item = { name: item, url: item };
              }
              item.uid = item.uid || new Date().getTime() + temp++;
              return item;
            });
          } else {
            this.fileList = [];
            return [];
          }
        },
        deep: true,
        immediate: true
      }
    },
    mounted() {
      this.$nextTick(()=>{
        this.heightTestData = window.innerHeight - 300
      })
      this.showResult = false
      this.showSN = false
    },
    methods: {
      handleChange(value) {
        this.selectedLabel = this.moduleClassSelectList.find(option => option.value === value).label;
        this.form = {}
        this.$set(this.form, "itr", value)
        this.showResult = false
        this.showSN = false
        this.logText = null
        this.control0 = null
        this.control1 = null
        this.control2 = null
        this.control3 = null
        this.control4 = null
        this.loglineChartData = {}
        // this.abk = null
        this.fileList = []
      },
      getChartDataForItem(item) {
          return this[`loglineChartData${item}`];

      },
      showWdModel1() {
        this.wdModel1 = true
      },
      showWdModel2() {
        this.wdModel2 = true
      },
      showLogModel() {
        this.logModel = true
      },
      // 上传前校检格式和大小
      handleBeforeUpload(file) {
        // 校检文件类型
        if (this.fileType) {
          const fileName = file.name.split('.');
          const fileExt = fileName[fileName.length - 1];
          const isTypeOk = this.fileType.indexOf(fileExt) >= 0;
          if (!isTypeOk) {
            this.$modal.msgError(`文件格式不正确, 请上传${this.fileType.join("/")}格式文件!`);
            return false;
          }
        }
        // 校检文件大小
        if (this.fileSize) {
          const isLt = file.size / 1024 / 1024 < this.fileSize;
          if (!isLt) {
            this.$modal.msgError(`上传文件大小不能超过 ${this.fileSize} MB!`);
            return false;
          }
        }
        // this.$modal.loading("正在上传文件，请稍候...");
        // this.number++;
        this.fileList = [file]
        return true;
      },
      // 上传前校检格式和大小
      handleBeforeUpload2(file) {
        // 校检文件类型
        if (this.fileType) {
          const fileName = file.name.split('.');
          const fileExt = fileName[fileName.length - 1];
          const isTypeOk = this.fileType.indexOf(fileExt) >= 0;
          if (!isTypeOk) {
            this.$modal.msgError(`文件格式不正确, 请上传${this.fileType.join("/")}格式文件!`);
            return false;
          }
        }
        // 校检文件大小
        if (this.fileSize) {
          const isLt = file.size / 1024 / 1024 < this.fileSize;
          if (!isLt) {
            this.$modal.msgError(`上传文件大小不能超过 ${this.fileSize} MB!`);
            return false;
          }
        }
        // this.$modal.loading("正在上传文件，请稍候...");
        // this.number++;
        this.fileList2 = [file]
        return true;
      },
      // 文件个数超出
      handleExceed() {
        this.$modal.msgError(`上传文件数量不能超过 ${this.limit} 个!`);
      },
      // 获取文件名称
      getFileName(name) {
        // 如果是url那么取最后的名字 如果不是直接返回
        if (name.lastIndexOf("/") > -1) {
          return name.slice(name.lastIndexOf("/") + 1);
        } else {
          return name;
        }
      },
      // 对象转成指定字符串分隔
      listToString(list, separator) {
        let strs = "";
        separator = separator || ",";
        for (let i in list) {
          strs += list[i].url + separator;
        }
        return strs != '' ? strs.substr(0, strs.length - 1) : '';
      },
      computeParamHD(form){
        var that = this
        this.$refs.wform.validate(valid => {
          if (!valid) return
          let formData = new FormData()
          formData.append('wd',form.wd)
          formData.append('materialtype',form.materialtype)
          service.computeParamWD(formData).then(res => {
            this.$set(this.form, "ktb", res.data.value)
            this.wdModel1 = false
          }).catch((err)=>{
            if(err.code == 500){
              that.$modal.msgError(err.mas);
            }
          })
        })
      },
      computeParamWD(form){
        var that = this
        this.$refs.wform.validate(valid => {
          if (!valid) return
          let formData = new FormData()
          formData.append('wd',form.wd)
          formData.append('materialtype',form.materialtype)
          service.computeParamWD(formData).then(res => {
            this.$set(this.form, "wt", res.data.value)
            this.wdModel2 = false
          }).catch((err)=>{
            if(err.code == 500){
              that.$modal.msgError(err.mas);
            }
          })
        })
      },
      count(form){
        this.$refs.mform.validate(valid2 => {
          if (!valid2) return
          this.$refs.jform.validate(valid3 => {
            if (!valid3) return
            console.log(form)
            console.log(this.$refs)
            if(this.fileList.length==0){
              this.$modal.msgError(`请上传正应力疲劳载荷谱文件!`);
              return false
            }
            if(this.fileList2.length==0){
              this.$modal.msgError(`请上传切应力疲劳载荷谱文件!`);
              return false
            }
            let zfile = this.fileList[0]
            let qfile = this.fileList2[0]
            let formData = new FormData()
            formData.append('zfile',zfile)
            formData.append('qfile',qfile)
            formData.append('ddc',form.ddc)
            formData.append('snleft',form.snleft)
            formData.append('sn1for',form.sn1for)
            formData.append('sn2for',form.sn2for)
            formData.append('ddcfor',form.ddcfor)
            formData.append('dm1',form.dm1)
            formData.append('dm2',form.dm2)
            formData.append('dtc',form.dtc)
            formData.append('tnleft',form.tnleft)
            formData.append('tn1for',form.tn1for)
            formData.append('tn2for',form.tn2for)
            formData.append('dtcfor',form.dtcfor)
            formData.append('tm1',form.tm1)
            formData.append('tm2',form.tm2)
            formData.append('ft',form.ft)
            formData.append('wt',form.wt)
            formData.append('cv',form.cv)
            formData.append('ds',form.ds)
            formData.append('dt',form.dt)
            formData.append('itr',form.itr)
            service.iiw200829Forecast(formData).then(res => {
              this.showResult = true
              this.showSN = true
              this.logText = res.data.contents
              this.loglineChartData1.xData = ""
              this.loglineChartData1.yData = ""
              this.loglineChartData1.title = this.selectedLabel1+"图"
              this.loglineChartData1.xmin = res.data.control[1]
              this.loglineChartData1.xmax = res.data.control[2]
              this.loglineChartData1.ymin = res.data.control[3]
              this.loglineChartData1.ymax = res.data.control[4]
              this.loglineChartData1.data = res.data.sn1

              this.loglineChartData2.xData = ""
              this.loglineChartData2.yData = ""
              this.loglineChartData2.title = this.selectedLabel2+"图"
              this.loglineChartData2.xmin = res.data.control[5]
              this.loglineChartData2.xmax = res.data.control[6]
              this.loglineChartData2.ymin = res.data.control[7]
              this.loglineChartData2.ymax = res.data.control[8]
              this.loglineChartData2.data = res.data.sn2
              this.k0 = res.data.control[0].toExponential()
            }).catch((err)=>{
              if(err.code == 500){
                that.$modal.msgError(err.mas);
              }

            })
          })
        })
      }
    }
  };
</script>

<style scoped lang="scss">
  .app-container {
    display: block;
    padding: 5px;
    height: calc(100%);
  }
  .container-bottom{
    height: calc(100% - 295px);
    overflow: hidden;
  }

  .detail-title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-weight: bold;
    font-size: 20px;

    &:before, &:after {
      content: '';
      display: inline-block;
      width: 37%;
      height: 4px;
      border-bottom: 1px solid #BAD7EC;
      border-top: 1px solid #BAD7EC;
    }
  }

  .detail-title-form {
    width: 450px;
    margin: 10px auto;
    ::v-deep .el-form-item{
      margin-bottom: 15px;
    }
    ::v-deep .el-form-item__label {
      color: #084EBC;
      font-weight: normal;
    }
  }

  .container {
    width: 100%;
    display: flex;
    justify-content: space-around;
  }

  .container-warp {
    width: 100%;
    display: inline-block;
    border: 1px solid #ddd;
    background-color: #fff;
    box-shadow: 0 0 5px #eeeeee;
  }

  .container-right {
    .container-warp + .container-warp {
      margin-top: 10px;
    }
  }

  .container-left {
    width: 49%;
  }

  .container-right {
    width: 49%;
  }

  .detail-center-btn {
    display: block;
    width: 260px;
    margin: 6px auto;
  }

  .table-title {
    font-size: 14px;
    font-weight: 400;
    line-height: 21px;
    height: 26px;
    color: #5184ec;
    text-indent: 10px;
    border-bottom: 1px solid #d5d5d5;
    background: url("../../../assets/images/line.png") no-repeat;
    background-position: -143px 22px;
  }

  .material-pic {
    background-color: #fff;
    border: 1px solid #CCDCE7;
    border-radius: 5px;
    width: 100%;
    max-width: 330px;
    height: 190px;
    margin-top: 15px;
    margin-left: 5px;
    display: flex;
    align-items: center;
    justify-content: center;

    img {
      width: 209.28px;
      height: 173.6px;
    }
  }
  .material-form1 {
    margin-top: 10px;

    ::v-deep .el-form-item__label {
      font-weight: normal;
    }

    ::v-deep .el-form-item {
      width: 20%;
      height:20px;
      margin-bottom: 12px;
    }

    ::v-deep .el-input--medium {
      width: calc(100%);
    }

    ::v-deep .el-select {
      .el-input--medium {
        width: 100% !important;
      }

      width: calc(100% - 70px) !important;
    }
    ::v-deep .el-form-item--medium .el-form-item__content {
        line-height: 24px !important;
    }
    ::v-deep .el-input--medium .el-input__inner {
        height: 28px !important;
    }
  }

  .material-form {
    margin-top: 10px;

    ::v-deep .el-form-item__label {
      font-weight: normal;
    }

    ::v-deep .el-form-item {
      width: 46%;
      margin-bottom: 12px;
    }

    ::v-deep .el-input--medium {
      width: calc(100% - 70px);
    }

    ::v-deep .el-select {
      .el-input--medium {
        width: 100% !important;
      }

      width: calc(100% - 70px) !important;
    }
  }

  .label-title {
    width: 133px;
    font-size: 14px;
    font-weight: 400;
    line-height: 24px;
    height: 26px;
    color: #5184ec;
    text-indent: 10px;
    border-left: 3px solid #166BCE;
    background: url("../../../assets/images/label_bg.png") no-repeat;
    background-size: 100%;
  }


  .log-warp {
    width: 96%;
    margin-left: 2%;
    border: 1px solid #ddd;
    border-radius: 5px;
    overflow: hidden;
    padding: 5px 10px;
    height: 100%;
    font-size: 14px;
  }

  .label-log-form {
    margin-top: 5px;
    text-align: center;
  }

  .log-warp + .detail-center-btn {
    width: 300px;
  }

  .label-subscript {
    display: inline-block;
    // width: 70px;
  }
  .dg-label-subscript {
    display: inline-block;
    width: 100px;
  }

  .structure-form {
    .label-subscript {
      width: 90px;
    }
  }

  .structure-form {
    margin-top: 10px;
    padding: 0 10px;

    ::v-deep .el-form-item__label {
      font-weight: normal;
    }

    ::v-deep .el-form-item {
      width: 31%;
      margin-bottom: 5px !important;
    }

    ::v-deep .el-input--medium {
      width: calc(100% - 90px);
      margin-bottom: 5px !important;
    }

    ::v-deep .el-input-group__append {
      padding: 0 6px;
    }

    ::v-deep .el-select {
      .el-input--medium {
        width: 100% !important;
      }

      width: calc(100% - 90px) !important;
    }
    ::v-deep .el-cascader {
      .el-input--medium {
        width: 100% !important;
      }

      width: calc(100% - 90px) !important;
    }

  }

  .dg-structure-form {
    margin-top: 10px;
    padding: 0 10px;

    ::v-deep .el-form-item__label {
      font-weight: normal;
    }

    ::v-deep .el-form-item {
      width: 46%;
      margin-bottom: 5px !important;
    }

    ::v-deep .el-input--medium {
      width: calc(100% - 100px);
      margin-bottom: 5px !important;
    }

    ::v-deep .el-input-group__append {
      padding: 0 6px;
    }
    ::v-deep .el-select {
      .el-input--medium {
        width: 100% !important;
      }

      width: calc(100% - 100px) !important;
    }
  }

  .structure-forms {
    margin-top: 10px;
    padding: 0 10px;

    ::v-deep .el-form-item__label {
      font-weight: normal;
    }

    ::v-deep .el-form-item {
      width: 48%;
      margin-bottom: 15px !important;
    }

    ::v-deep .fy {
      width: 31%;
    }

    /*::v-deep .fy .el-tooltip {*/
    /*  width: 90px !important;*/
    /*}*/

    /*::v-deep .fy .el-input--medium {*/
    /*  width: calc(100% - 90px)  !important;*/
    /*}*/

    ::v-deep .el-form-item__content {
      width: calc(100% - 125px);
    }

    .form-label-tooltip {
      ::v-deep .el-form-item__content {
        width: 100%;
      }

      ::v-deep .el-tooltip {
        width: 50px;
        display: inline-block;
      }

      ::v-deep .el-input--medium {
        width: calc(100% - 50px);
      }
    }
  }
  .divcontainer {
    position: relative;
  }

  .badge {
    position: absolute;
    cursor: pointer;
    top: -5px;
    right: -10px;
    width: 30px;
    height: 30px;
    background-color: #ffffff;
    color: white;
    /* border-radius: 50%; */
    text-align: center;
    line-height: 30px;
  }
  .chart-warp{
    .el-carousel__item{
      width: 80%;
      margin-left: 10%;
    }
  }
  .line-warp{
    width: 98%;
    height: 4px;
    border-top: 1px dashed #bad7ec;
    border-bottom: 1px dashed #bad7ec;
    margin: 6px 1%;
  }
  ::v-deep .el-carousel__container{
    height: 100%;
  }
  .upload-file-uploader {
    margin-bottom: 5px;
    margin-left: auto;
    margin-right: auto;
  }
  .upload-file-list .el-upload-list__item {
    border: 1px solid #e4e7ed;
    line-height: 2;
    margin-bottom: 10px;
    position: relative;
  }
  .upload-file-list .ele-upload-list__item-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: inherit;
  }
  .ele-upload-list__item-content-action .el-link {
    margin-right: 10px;
  }
  .fyzh{
    display: inline-flex;
    width: 100%;
  }
  /* CSS 类用于换行 */
  .wrap-text {
    white-space: pre-line;
  }

  /* 用于处理长单词或 URL 的换行 */
  .break-word {
    word-break: break-all;
    overflow-wrap: break-word;
  }

  ::v-deep .el-form-item.is-required:not(.is-no-asterisk)>.el-form-item__label:before{
      // content: '*' !important;
      display: none
  }

</style>
